<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>华丽的登录页</title>
</head>
<body>

<h2>华丽的登录页</h2>
<!--suppress HtmlUnknownTarget -->
<form id="myForm" action="/login" method="post">
    用户名: <input type="text" name="username"/>
    <br>
    密码: <input type="password" name="password"/>
    <br>
    <input id="mySubmit" type="button" value="点击登录"/>
</form>

<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
    $('#mySubmit').bind("click",function(){

        var form = new FormData(document.getElementById("myForm"));
        $.ajax({
            type: "post",
            url: "/login",
            processData:false,
            contentType:false,
            data: form,
            dataType: "json",
            success: function(res) {
                console.log(res)
                if (res.resultStatus === "00000"){
                    window.location.href = "doc.html";
                }else {
                    alert(res.resultIns);
                }
            },
            error: function() {
                alert("连接服务器失败...")
            }
        })
    });
</script>
</body>
</html>